import { useLocation, Navigate } from "react-router-dom";

export function withLogin(Comp) {
  return function() {
    // 拦截
    const token = localStorage.getItem('token');
    const { pathname } = useLocation()
    if(!token && pathname !== '/login') {
      return <Navigate to="/login"></Navigate>
    }

    return <Comp></Comp>
  }
}